package com.zhiying.crawler.dao;


import com.zhiying.crawler.dto.BookDTO;
import com.zhiying.crawler.dto.SortDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookDao {

    Integer saveBookInfo(List<BookDTO> bookDTOs);

    @Select("select * from book where sort_link=#{sortLink} and book_name=#{bookName}")
    BookDTO getBookByNameAndSortLink(@Param("sortLink") String sortLink, @Param("bookName") String bookName);

    /*not in的结果集中出现null则查询结果为null;  !=null不起作用 要用is not null*/
    @Select("select sort_link,sort_page from sort where sort_link not in (select sort_link from book where sort_link is not null)  and sort_page is not null")
    List<SortDTO> getinExistSortLink();

    @Select("select * from book where status='N' ")
    List<BookDTO> getUntrackBooks();

    @Update("update book set book_page=#{bookPage} where book_link=#{bookLink}")
    Integer updateBookContent(@Param("bookPage") String bookPage, @Param("bookLink") String bookLink);

    @Select("select * from book where book_link=#{bookLink}")
    BookDTO getBookByBookLink(@Param("bookLink") String bookLink);

}
